<?php
class PlaylistController extends mcz_Controller
{
	public function __construct()
	{
		if(!$_SESSION['obj']->isAuth())
		{
			header('location: ' . mczURL('/auth'));
			die;
		}
		$this->setLayout('layout');
	}

	public function showAction($id)
	{
		$pls = mcz_Playlist::find($id);
		if(!$pls)
		{
			die;
		}
		if($pls->user_id != $_SESSION['obj']->id)
		{
			//die;
		}
		$this->display('playlist', array(
			'playlistName' => $pls->title,
			'tunes' => $pls->findItems()
		));
	}
	
	public function allAction()
	{
		$lists = mcz_Playlist::findAll();
		$this->display('playlists', array(
			'lists' => $lists
		));
	}
}